



//
//  MBZuFuWuVC.m
//  房源详情-小区详情
//
//  Created by MB__Lee on 2018/5/28.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "MBZuFuWuVC.h"

#import "MBCoTool.h"

#import "MBFisrtCoCell.h"

#import "MBCommonMethod.h"

#define Item_Width MBScale(65)
#define Item_hight 70

@interface MBZuFuWuVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>


@property(nonatomic,strong)UICollectionView *collectionView;
@property(nonatomic,strong)NSMutableArray *mut; //数据源

@property(nonatomic,strong)MBCommonMethod *commonPush;
@end

static NSString *MBFisrtCoCell_Identi = @"MBFisrtCoCell";

@implementation MBZuFuWuVC
-(MBCommonMethod *)commonPush{
    if (!_commonPush) {
        _commonPush = [[MBCommonMethod alloc] init];
    }
    return _commonPush;
}

-(NSMutableArray *)mut{
    if (!_mut) {
        _mut = [MBCoTool MBCoToolCreat_zuFuWuSource];
    }
    return  _mut;
}
-(UICollectionView *)collectionView{
    if (!_collectionView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake(Item_Width, Item_hight);
        layout.minimumInteritemSpacing = MBScale(15);
        layout.minimumLineSpacing = 5;
        
        CGRect frame ;
        frame.origin.x = 0;
        frame.origin.y = 0;
        frame.size.width = self.view.bounds.size.width;
        frame.size.height = self.view.bounds.size.height + 20;
        
        
        UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:frame collectionViewLayout:layout];
        _collectionView = collectionView;
        
        
        
        collectionView.backgroundColor = [UIColor whiteColor];
        
        [collectionView registerNib:[UINib nibWithNibName:MBFisrtCoCell_Identi bundle:nil] forCellWithReuseIdentifier:MBFisrtCoCell_Identi];
        
        collectionView.delegate = self;
        collectionView.dataSource = self;
        
    }
    return  _collectionView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.view addSubview:self.collectionView];
    [self addLine];
    
    
}
-(void)addLine{
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
    line.backgroundColor = MBLitterLineColor;
    [self.collectionView addSubview:line];
}

#pragma mark --UICollectionViewDelegate-UICollectionViewDataSource
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.mut.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    MBFisrtCoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:MBFisrtCoCell_Identi forIndexPath:indexPath];
    
    if (self.mut.count) {
        cell.model = self.mut[indexPath.row];
    }
    
    return  cell;
    
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return  UIEdgeInsetsMake(10, 20, 0, 20);
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    [self.commonPush CommonMethod_ZuFuWuPushWithIndexPath:indexPath viewController:self];
    
}


@end
